﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace BetterWebBooking.Account
{
    public partial class Register1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string username = UserName.Text.Trim();
            string password = Password.Text.Trim();
            string name = Name.Text.Trim();
            string address = Address.Text.Trim();
            string zip = Zip.Text.Trim();
            string email = Email.Text.Trim();
            BetterWebBooking.CodeFolder.DBHelper.CreateUser(username, name, address, zip, email, password);
            Session["User"] = username;
            FormsAuthentication.SetAuthCookie(username, false);

            string returnUrl = Request.QueryString["ReturnUrl"] as string;

            if (returnUrl != null)
            {
                Response.Redirect(returnUrl);
            }
            else
            {
                //no return URL specified so lets kick him to home page
                Response.Redirect("~/Default.aspx");
            }

        }
    }
}